<template>
  <base-breadcrumb>
    <template>
      <a-card class="table-page-search-wrapper">
        <titleName title="信息详情" />
        <a-form
          :label-col="{ lg: { span: 6 }, sm: { span: 6 } }"
          :wrapper-col="{ lg: { span: 16 }, sm: { span: 16 } }"
        >
          <a-row :gutter="24">
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="名称">
                {{ fromObj.name }}
              </a-form-item>
            </a-col>
            <!-- <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="所属单位">
                {{ fromObj.branchComName+'/'+fromObj.projectName }}
              </a-form-item>
            </a-col> -->
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="所属分公司">
                {{ fromObj.branchComName }}
              </a-form-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="所属项目">
                {{ fromObj.projectName }}
              </a-form-item>
            </a-col>

            <a-col
              :md="8"
              :sm="6"
            >
              <a-form-item label="当前状态">
                <span v-if="fromObj.auditStatus === 'DRAFT'">草稿</span>
                <span v-if="fromObj.auditStatus === 'SUBMITTED'">已提交</span>
                <span v-if="fromObj.auditStatus === 'PAST'">通过</span>
                <span v-if="fromObj.auditStatus === 'REJECTED'">驳回</span>
              </a-form-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="填报人">
                {{ fromObj.creatorName }}
              </a-form-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-item label="填报时间">
                {{ fromObj.createTime }}
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </a-card>
    </template>
    <!-- 附件 -->
    <a-card>
      <titleName title="项目策划书文件" />
      <a-table
        bordered
        :columns="enclosure"
        :data-source="fromObj.fileInfoVOList"
        :pagination="false"
      >
        <span
          slot="serial"
          slot-scope="text, record, index"
        >{{ index + 1 }}</span>
        <span
          slot="action"
          slot-scope="text, record"
        >
          <a
            :href="
              '/api/ycloud-file-center/oper/download?access_token=' + token + '&fileId=' + record.fileId
            "
          >下载</a>
          <a-divider type="vertical" /> <a
            :key="record.fileId"
            @click="$filePreview(record)"
          >查看</a></span>
      </a-table>
    </a-card>
    <div class="tool-btns page-btn-right-top">
      <a-button
        v-if="checkVisibleInDetail"
        class="ml20"
        type="primary"
        @click="closeForm"
      >
        关闭
      </a-button>
    </div>
  </base-breadcrumb>
</template>

<script>
import { detailed } from '@/api/businessAffairs/planBook'
import Vue from 'vue'
import { isAttachment, checkVisibleInDetail } from '@/utils/util'
const enclosure = [
    {
        title: '序号',
        width: '80px',
        scopedSlots: { customRender: 'serial' }
    },
    {
        title: '附件名称',
        dataIndex: 'fileName'
    },

    {
        title: '格式',
        dataIndex: 'suffixName'
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
    }
]
export default {
    name: 'a' + Date.now(),
    mounted() {
        this.token = Vue.getAcloudProvider().getAccessToken()
        detailed(this.$route.query.id).then((res) => {
            if (res.code === 200) {
                this.fromObj = res.data
            } else {
                this.$message.error('加载失败')
            }
        })
    },
    props: {
        isAudit: {
            // 是否作为审批详情
            type: Boolean,
            default: false
        }
    },
    watch: {
        isAudit: {
            immediate: true,
            handler(val) {
                if (val) {
                    // this.$nextTick(() => {
                    //     this.pageType = 'look'
                    // })
                }
            }
        }
    },
    methods: {
        closeForm() {
            if (this.isAudit) {
                window.close()
            } else {
                this.$multiTab.close(this.$route.fullpath)
            }
        }
    },
    data() {
        this.enclosure = enclosure
        return {
            checkVisibleInDetail: checkVisibleInDetail(this),
            fromObj: {},
            token: ''
        }
    }
}
</script>

<style>
</style>